package preadd.p2;

import java.util.Arrays;
import java.util.stream.IntStream;

public class test724 {
    public static void main(String[] args) {
        int nums[] = {-1,-1,0,1,1,0};
        Solution solution = new Solution();
        int index = solution.pivotIndex(nums);
        System.out.println(index);
    }
}
class Solution {
    public int pivotIndex(int[] nums) {
        int ls=0;
        int rs=0;
         rs = Arrays.stream(nums).sum();
        for(int i=0;i<nums.length;i++){
            rs-=nums[i];
            if(ls==rs){
                return i;
            }
            ls+=nums[i];
        }
        return -1;
    }
}
